package com.catsic.zcjc.dao;

import java.util.List;

import javax.persistence.QueryHint;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;

import com.catsic.base.BaseDao;
import com.catsic.zcjc.entity.EquipData;


public interface EquipDataDao extends BaseDao<EquipData, String>{
	
	@Query("select e from EquipData e where e.equip.id = ?1 and (plateNo is not null and plateNo<>'') ")
	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
	public List<EquipData> findByEquipId(String equipId);
	

	@Query("select e from EquipData e where e.station.id = ?1  and (plateNo is not null and plateNo<>'')  ")
	@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value ="true") })
	public List<EquipData> findByStationId(String stationId);
	
	//@Query("select e from EquipData e where e.station.id = ?1 and  (plateNo is not null and plateNo<>'')   order by collectionTime desc")
	@Query(value = "select e.* from T_EQUIP_DATA e where e.STATION_ID = ?1 and  (PLATE_NO is not null and PLATE_NO<>'')   order by COLLECTION_TIME desc limit 1",nativeQuery  = true)
	public EquipData findFirstByStationOrderByCollectionTimeDesc(String stationId);
}
